package LeetCode.LeetCode2;

public class Num063 {
    public int maxProfit(int[] prices) {
        if(prices.length <= 1){
            return 0;
        }
        int maxNum = prices[1] - prices[0];
        for (int i = 0; i < prices.length; i++) {
            for (int j = i + 1; j < prices.length; j++) {
                if(prices[i] < prices[j] && prices[j] - prices[i] > maxNum){
                    maxNum = prices[j] - prices[i];
                }else{
                    continue;
                }
            }
        }
        if (maxNum >= 0){
            return maxNum;
        }else{
            return 0;
        }
    }
}
